package top.chmin.project.cloud.common.entity.auto;

// field import auto
// #bind.field.id#

import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import top.chmin.project.cloud.common.entity.*;

/**
 * chmin
 * 2023-12-27 14:43:40
 * cloud-builder
 */
@Getter
@Setter
@Accessors(chain = true)
public class Entity extends Model {

    // field auto
// #bind.field.tableName#
    // 表名
    private String tableName;
// $bind.field.tableName$

    // #bind.field.prefix#
    // 表前缀
    private String prefix;
// $bind.field.prefix$

    // #bind.field.className#
    // 类名
    private String className;
// $bind.field.className$

    // #bind.field.module#
    // 模块
    private String module;
// $bind.field.module$

    // #bind.field.pack#
    // 包名
    private String pack;
// $bind.field.pack$

    // #bind.field.path#
    // 相对路径
    private String path;
// $bind.field.path$

    // #bind.field.remark#
    // 备注
    private String remark;
// $bind.field.remark$

    // #bind.field.tableCode#
    // 实体编码
    private String tableCode;
// $bind.field.tableCode$


    @Override
    public EntityEPC getPreCondition() {
        return new EntityEPC();
    }

    public class EntityEPC extends PreCondition {
        private EntityEPC() {
        }

        private EntityEPC(EntityEPC parent) {
            super(parent);
        }

        public EntityEPC forUpdate() {
            addUpdateSql("update_time = ?", updateTime);
            addUpdateSql("update_by = ?", updateBy);
// field update auto
// #bind.field.tableName#
            addUpdateSql("table_name = ?", tableName);
// $bind.field.tableName$

// #bind.field.prefix#
            addUpdateSql("prefix = ?", prefix);
// $bind.field.prefix$

// #bind.field.className#
            addUpdateSql("class_name = ?", className);
// $bind.field.className$

// #bind.field.module#
            addUpdateSql("module = ?", module);
// $bind.field.module$

// #bind.field.pack#
            addUpdateSql("pack = ?", pack);
// $bind.field.pack$

// #bind.field.path#
            addUpdateSql("path = ?", path);
// $bind.field.path$

// #bind.field.remark#
            addUpdateSql("remark = ?", remark);
// $bind.field.remark$

// #bind.field.tableCode#
            addUpdateSql("table_code = ?", tableCode);
// $bind.field.tableCode$

            type = "UPDATE";
            return this;
        }

        public EntityEPC forDelete() {
            type = "DELETE";
            return this;
        }

        public EntityEPC forCount() {
            type = "COUNT";
            return this;
        }

        public EntityEPC sub() {
            return new EntityEPC(this);
        }

        public EntityEPC complete(boolean and) {
            finish(and);
            return parent == null ? this : (EntityEPC) parent;
        }

        public EntityFPC toFlex() {
            EntityFPC flex = new EntityFPC();
            flex.setUpdateSqlList(updateSqlList);
            flex.setUpdateValueList(updateValueList);
            flex.setSqlList(sqlList);
            flex.setValueList(valueList);
            flex.setType(type);
            return flex;
        }

        public Condition toCondition() {
            return toCondition(Entity.class, "bs_entity");
        }

        // field epc auto
// #bind.field.id#
        public Id id() {
            return new Id();
        }

        public class Id extends LongEPCField<EntityEPC> {
            private Id() {
                super(EntityEPC.this, "id", id);
            }
        }
// $bind.field.id$

        // #bind.field.createBy#
        public CreateBy createBy() {
            return new CreateBy();
        }

        public class CreateBy extends StringEPCField<EntityEPC> {
            private CreateBy() {
                super(EntityEPC.this, "create_by", createBy);
            }
        }
// $bind.field.createBy$

        // #bind.field.updateBy#
        public UpdateBy updateBy() {
            return new UpdateBy();
        }

        public class UpdateBy extends StringEPCField<EntityEPC> {
            private UpdateBy() {
                super(EntityEPC.this, "update_by", updateBy);
            }
        }
// $bind.field.updateBy$

        // #bind.field.createTime#
        public CreateTime createTime() {
            return new CreateTime();
        }

        public class CreateTime extends LocalDateTimeEPCField<EntityEPC> {
            private CreateTime() {
                super(EntityEPC.this, "create_time", createTime);
            }
        }
// $bind.field.createTime$

        // #bind.field.updateTime#
        public UpdateTime updateTime() {
            return new UpdateTime();
        }

        public class UpdateTime extends LocalDateTimeEPCField<EntityEPC> {
            private UpdateTime() {
                super(EntityEPC.this, "update_time", updateTime);
            }
        }
// $bind.field.updateTime$

        // #bind.field.tableName#
        public TableName tableName() {
            return new TableName();
        }

        public class TableName extends StringEPCField<EntityEPC> {
            private TableName() {
                super(EntityEPC.this, "table_name", tableName);
            }
        }
// $bind.field.tableName$

        // #bind.field.prefix#
        public Prefix prefix() {
            return new Prefix();
        }

        public class Prefix extends StringEPCField<EntityEPC> {
            private Prefix() {
                super(EntityEPC.this, "prefix", prefix);
            }
        }
// $bind.field.prefix$

        // #bind.field.className#
        public ClassName className() {
            return new ClassName();
        }

        public class ClassName extends StringEPCField<EntityEPC> {
            private ClassName() {
                super(EntityEPC.this, "class_name", className);
            }
        }
// $bind.field.className$

        // #bind.field.module#
        public Module module() {
            return new Module();
        }

        public class Module extends StringEPCField<EntityEPC> {
            private Module() {
                super(EntityEPC.this, "module", module);
            }
        }
// $bind.field.module$

        // #bind.field.pack#
        public Pack pack() {
            return new Pack();
        }

        public class Pack extends StringEPCField<EntityEPC> {
            private Pack() {
                super(EntityEPC.this, "pack", pack);
            }
        }
// $bind.field.pack$

        // #bind.field.path#
        public Path path() {
            return new Path();
        }

        public class Path extends StringEPCField<EntityEPC> {
            private Path() {
                super(EntityEPC.this, "path", path);
            }
        }
// $bind.field.path$

        // #bind.field.remark#
        public Remark remark() {
            return new Remark();
        }

        public class Remark extends StringEPCField<EntityEPC> {
            private Remark() {
                super(EntityEPC.this, "remark", remark);
            }
        }
// $bind.field.remark$

        // #bind.field.tableCode#
        public TableCode tableCode() {
            return new TableCode();
        }

        public class TableCode extends StringEPCField<EntityEPC> {
            private TableCode() {
                super(EntityEPC.this, "table_code", tableCode);
            }
        }
// $bind.field.tableCode$

    }
}
